package com.csi.controller.back;

import com.csi.domain.Result;
import com.csi.service.LocationService;
import com.csi.utils.ReturnResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 位置管理
 */
@RequestMapping("/location")
@RestController
public class LocationController {

    @Autowired
    private LocationService locationService;

    /**
     * 根据上一级id查询地区(省、市、县)
     * @param areaId
     * @return
     */
    @GetMapping("area")
    public Object getArea(@RequestParam("id") long areaId){
        Map<String,Object> areaList =  locationService.getAllArea(areaId);
        if (!areaList.isEmpty() && areaList != null ){
            return  new Result<Map<String,Object>>("查找成功！", ReturnResults.ACCESS_SUCCESS,areaList);
        }
        return new Result<>("查找失败！",ReturnResults.ACCESS_FAILED);
    }
}
